CC = ${COMPILER_PREFIX}gcc
CFLAGS = -c -Wall  -I. -I/usr/local/include
LDFLAGS = -lpthread -L/usr/local/lib -lpcre2-8

SOURCES = txt2mobi.c htmllib.c  str_resource.c libs.c pcre2lib.c
OBJECTS = $(SOURCES:.c=.o)
EXECUTABLE = mobi_convert

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
	$(CC) $(OBJECTS) -o $@ $(LDFLAGS) 

.c.o:
	$(CC) $(CFLAGS) $< -o $@

clean:
	rm -f *.o $(EXECUTABLE)
	rm -f chapter*.html *.mobi *.opf *.ncx book-toc.html
